<?php
class GanttController extends Controller {
    public $metaDescription = null;
    public $metaKeywords = null;
    public $linkCanoncical = null;
    public $title = null;
    public $layout = "column_project";

    public function actionIndex(){
        //$this->layout='column_project';        
        $url = new Url();     
        $project_id = $_SESSION['project_pm']['project_id'];
        $user_id = $_SESSION['user_pm']['user_id'];

        $data_task = Task::getRowByProjectId($project_id,0);        
        /*echo "<pre>";
        print_r($data_task);
        echo "</pre>";
        die;*/

        $data = array();
        foreach($data_task as $row){
            switch($row['task_priority']){
                case 1:
                    $test = Assign::getRowsByTaskID($row['task_id']);
                    $data[] = array(
                    'label' => $row['task_name'],
                    'start' => date('Y-m-d',$row['task_start_date']), 
                    'end'   => date('Y-m-d',$row['task_end_date']),
                    'link'   => $url->createUrl("task/detail",array("task_id"=>$row['task_id'])),
                    'count'   => count($test),
                    );    
                    break;
                case 2:
                    $test = Assign::getRowsByTaskID($row['task_id']);
                    $data[] = array(
                    'label' => $row['task_name'],
                    'start' => date('Y-m-d',$row['task_start_date']), 
                    'end'   => date('Y-m-d',$row['task_end_date']),
                    'link'   => $url->createUrl("task/detail",array("task_id"=>$row['task_id'])),
                    'count'   => count($test),
                    'class' => 'urgent',
                    );    
                    break;
                case 3:
                    $test = Assign::getRowsByTaskID($row['task_id']);
                    $data[] = array(
                    'label' => $row['task_name'],
                    'start' => date('Y-m-d',$row['task_start_date']), 
                    'end'   => date('Y-m-d',$row['task_end_date']),
                    'link'   => $url->createUrl("task/detail",array("task_id"=>$row['task_id'])),
                    'count'   => count($test),
                    'class' => 'important',
                    );    
                    break;
            }            
        }        

        /*echo "<pre>";
        print_r($data);
        echo "</pre>";
        die;*/

        $this->render('index',array("data"=>$data));
    }    

}